<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>办公系统 - 基础表格</title>
    <meta name="keywords" content="办公系统">
    <meta name="description" content="办公系统">

    <link rel="shortcut icon" href="favicon.ico">
    	<link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/select/bootstrap-select.min.css" rel="stylesheet">
	<link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">

      <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>员工管理<small>>添加信息</small></h5>
                    </div>
                    <div class="ibox-content">
                        <form id="saveForm" class="form-horizontal">
                       	<div class="row">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">姓名</label>
                                <div class="col-sm-3">
                                    <input name="ename" type="text" class="form-control input-sm">
                                </div>
                                <label class="col-sm-2 col-sm-offset-1 control-label">用户名</label>
                                <div class="col-sm-3">
                                    <input name="username" type="text" class="form-control input-sm">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">密码</label>
                                <div class="col-sm-3">
                                    <input name="password" type="text" class="form-control input-sm">
                                </div>
                                <label class="col-sm-2 col-sm-offset-1 control-label">性别</label>
                                <div class="col-sm-3">
                                    <select name="esex" class="selectpicker form-control">
										<option>男</option>
										<option>女</option>
									</select>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">身份证号码</label>
                                <div class="col-sm-3">
                                    <input name="pnum" type="text" class="form-control input-sm">
                                </div>
                                <label class="col-sm-2 col-sm-offset-1 control-label">联系电话</label>
                                <div class="col-sm-3">
                                    <input name="telephone" type="text" class="form-control input-sm">
                                </div>
                            </div>
                        </div>

                        <div class="row">
                              <label class="col-sm-2 control-label">部门</label>
                                <div class="col-sm-3">
                                    <select name="dfk" class="form-control">
										<!-- <option>Mustard</option>
										<option>Ketchup</option>
										<option>Relish</option> -->
									</select>
                                </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-offset-1 control-label">入职时间</label>
                                <div class="col-sm-3">
                                    <!--时间控件的id都不能改-->
                                    <input name="hiredate" id="start" class="laydate-icon form-control layer-date">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="form-group">
                              <div class="form-group">
                                <label class="col-sm-2 control-label">年龄</label>
                                <div class="col-sm-3">
                                    <input name="eage" type="text" class="form-control input-sm">
                                </div>
                                <label class="col-sm-2 col-sm-offset-1 control-label">角色</label>
                                <div class="col-sm-3">
                                    <select name="roleid" class="form-control">
										<!-- <option>管理员</option>
										<option>VIP</option> -->
									</select>
                                </div>
                            </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">备注</label>
                                <div class="col-sm-9">
                                    <textarea name="remark" class="form-control"></textarea>
                                </div>

                            </div>
                        </div>

                     	<div class="row">
                     		<div class="hr-line-dashed"></div>
                     	</div>

                         <div class="row">
                            <div class="form-group">
                                <div class="col-sm-3 col-sm-offset-3 text-right">
                                    <button type="button" id="saveBtn" class="btn btn-primary"><i class="fa fa-save"></i> 保存内容</button>
                                </div>
                                <div class="col-sm-3">
                                	<a href="list-employee.html" class="btn btn-white"><i class="fa fa-reply"></i> 返回</a>
                                	</div>
                            </div>
                       </div>
                       </form>
                    </div>
                </div>
            </div>
        </div>
    </div>




    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.6"></script>
    <script src="js/plugins/sweetalert/sweetalert.min.js"></script>
	<script src="js/plugins/select/bootstrap-select.min.js"></script>
	<script src="js/plugins/layer/laydate/laydate.js"></script>
	<script src="js/jquery.serializejson.min.js" type="text/javascript" charset="utf-8"></script>
   <script>
	$(document).ready(function() {
		// 设置按钮的样式
		$('.selectpicker').selectpicker('setStyle', 'btn-white');
		//初始化日期控件
		laydate({elem: "#start"});

		$.ajax({
			url:"dept/all",
			type:"get",
			dataType:"json",
			success:function(ret){
				if(ret.status){
					$.each(ret.data.items,function(i,dept){
						$("select[name='dfk']").append('<option value="'+dept.deptno+'">'+dept.dname+'</option>')
					})
				}
			}
		})

		$.ajax({
			url:"role/all",
			type:"get",
			dataType:"json",
			success:function(ret){
				if(ret.status){
					$.each(ret.data.items,function(i,role){
						$("select[name='roleid']").append('<option value="'+role.roleid+'">'+role.rolename+'</option>')
					})
				}
			}
		})

		$("#saveBtn").click(function(){
			var roleid = $("select[name='roleid']").val()
			var data = $("#saveForm").serializeJSON()

			$.ajax({
				url:"emp/save/"+roleid,
				type:"post",
				data:JSON.stringify(data),
				dataType:"json",
				contentType:"application/json",
				success:function(ret){
					if(ret.status){
						window.location.href="list-employee.html"
					}
				}
			})

		})


		//--------------------下面是常用代码模版---------------------------------------

		//下拉列表使用ajax加载说明例子
		// function loadSelect(){
		// 	var option='<option value="0">-------请选择------</option><option value="4">用友软件</option><option selected value="5">浪潮软件</option>';
		// 	$("#company").html(option);
		// 	//ajax填充数据后需调用下面的方法来刷新下拉列表
		// 	$("#company").selectpicker('refresh');
		// }
		// loadSelect();

		// //点击按钮，消息提示框
		// $("#demo1").click(function() {
		// 	//基本消息框－留着备用
		// 	swal({
		// 		title: "恭喜，添加成功",
		// 		text: "数据添加成功，为您返回列表页！"
		// 	})
		// });

		// // 选择客户公司名称时自动选对应的客户方负责人
		// $("#company").change(function(){
		// 	var thisVal=$(this).val();
		// 	//val指value属性,选中value属性＝thisVal的选项
		// 	$('#customer').selectpicker('val',thisVal);
		// });

	});
   </script>
   <!-- 修复日期控件长度-->
   <link href="css/customer.css" rel="stylesheet">
</body>


</html>
